package com.heima.Config;

import com.heima.common.exception.RabbitMQcode;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SpringRabbitMQConfig {
    //    声明交换机
    @Bean
    public FanoutExchange ESfanoutExchange()
    {
        return new FanoutExchange(RabbitMQcode.ESExchangeName);
    }

    //    声明队列
    @Bean
    public Queue ESfanoutQueue()
    {
        return new Queue(RabbitMQcode.ESQueueName);
    }

    //    绑定交换机和队列
    @Bean
    public Binding ESbinding(Queue ESfanoutQueue, FanoutExchange ESfanoutExchange)
    {
        return BindingBuilder.bind(ESfanoutQueue).to(ESfanoutExchange);
    }
}
